<script setup>
import Editor from '@tinymce/tinymce-vue'
import { onMounted } from 'vue';
import {WordPaster} from '/public/WordPaster/js/w'
import {zyCapture} from '/public/zyCapture/z'
import {zyOffice} from '/public/zyOffice/js/o'
import '/public/WordPaster/js/w.css'

defineProps({
  msg: {
    type: String,
    required: true
  }
})
// 初始化
WordPaster.getInstance({
  // 上传接口：http://www.ncmem.com/doc/view.aspx?id=d88b60a2b0204af1ba62fa66288203ed
  PostUrl: 'http://localhost:52091/upload.aspx',
  // 为图片地址增加域名：http://www.ncmem.com/doc/view.aspx?id=704cd302ebd346b486adf39cf4553936
  ImageUrl: 'http://localhost:52091{url}',
  // 设置文件字段名称：http://www.ncmem.com/doc/view.aspx?id=c3ad06c2ae31454cb418ceb2b8da7c45
  FileFieldName: 'file',
  // 提取图片地址：http://www.ncmem.com/doc/view.aspx?id=07e3f323d22d4571ad213441ab8530d1
  ImageMatch: ''  
});
// zyCapture
zyCapture.getInstance({
  config: {
    PostUrl: 'http://localhost:52091/upload.aspx',
    ImageUrl: 'http://localhost:52091{url}',
    FileFieldName: 'file',
    Fields: { uname: 'test' }
  }
});

// zyoffice，
// 使用前请在服务端部署zyoffice，
// http://www.ncmem.com/doc/view.aspx?id=82170058de824b5c86e2e666e5be319c
zyOffice.getInstance({
  word: 'http://localhost:13710/zyoffice/word/convert',
  wordExport: 'http://localhost:13710/zyoffice/word/export',
  pdf: 'http://localhost:13710/zyoffice/pdf/upload'
})
</script>

<template>
  <Editor
    api-key="j35a41sl40sueex4hn3390d0j2pco42v2cu3d3ydy73rfrac"
    :init="{
      plugins: 'autosize lists link image table code help wordcount',
      toolbar: 'zycapture wordpaster importwordtoimg netpaster wordimport excelimport pptimport pdfimport importword exportword importpdf',
      width: '100%',
      external_plugins: {
        zycapture: '/public/zyCapture/plugin/zycapture.js',
        wordpaster: '/public/WordPaster/plugin/wordpaster.js',
        importwordtoimg: '/public/WordPaster/plugin/importwordtoimg.js',
        netpaster: '/public/WordPaster/plugin/netpaster.js',
        wordimport: '/public/WordPaster/plugin/wordimport.js',
        excelimport: '/public/WordPaster/plugin/excelimport.js',
        pptimport: '/public/WordPaster/plugin/pptimport.js',
        pdfimport: '/public/WordPaster/plugin/pdfimport.js',
        importword: '/public/zyOffice/plugin/importword.js',
        exportword: '/public/zyOffice/plugin/exportword.js',
        importpdf: '/public/zyOffice/plugin/importpdf.js'
      },
      setup:function(edt){
        edt.on('init', ()=>{
          edt.setContent('<p>泽优全平台内容发布解决方案 for TinyMCE 6-vue3-cli</p><p>泽优全平台Word一键粘贴控件（WordPaster）</p><p>泽优全平台截屏控件（zyCapture）</p><p>泽优Office文档转换服务（zyOffice）</p>')
        });
        edt.on('paste',function(e){
          WordPaster.getInstance().SetEditor(edt).PasteManual()
          e.preventDefault();
        })
      },
    }"
  />
</template>

<style scoped>
</style>
